package gdut.imis.controller;

import gdut.imis.Utils.Result;
import gdut.imis.service.MajorService;
import gdut.imis.vo.MajorVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author JiaFu
 * @Date 2023/4/8 18:17
 */
@RestController
@RequestMapping("/major")
@Api(value = "大学专业档案接口", tags = {"大学专业档案接口"})
@RequiredArgsConstructor
public class MajorController extends BaseController {
    private final MajorService majorService;

    @ApiOperation("录入大学专业档案(拥有major权限)")
    @PostMapping("/addMajor")
    @PreAuthorize("@cp.hasPermission('major')")
    public Result add(@RequestBody MajorVo majorVo) {
        return majorService.addMajor(majorVo);
    }

    @ApiOperation("获取专业列表")
    @GetMapping("/getMajorListByUniversityId/{universityId}")
    public Result getMajorList(@PathVariable("universityId") Long universityId){
        return majorService.getMajorList(universityId);
    }

    @ApiOperation("根据学院id获取专业列表")
    @GetMapping("/getMajorListByCollegeId/{collegeId}")
    public Result getMajorListByCollegeId(@PathVariable("collegeId") Long collegeId){
        return majorService.getMajorListByCollegeId(collegeId);
    }

}
